package com.tz.mapper;
import com.tz.entity.Poll;
import com.tz.entity.ResearchDetail;
import org.apache.ibatis.annotations.Param;
import org.mybatis.spring.annotation.MapperScan;
import java.util.List;
/**
 * Created by Administrator on 2018/1/2 0002.
 */
@MapperScan
public interface ResearchDetailMapper {
    /**
     * 添加一份调查明细
     */
    void insertResearchDetail(@Param("research_id") Long researchid,@Param("detail")ResearchDetail researchDetail);
    /**
     * 插入答案
     *
     * @param detailid
     * @param polls
     */
    void insertBatchPolls(@Param("detail_id")Long detailid,@Param("polls")List<Poll> polls);
    /**
     * 显示一次调查的所有明细
     * @param detailid
     * @return 一个明细
     */
    ResearchDetail selectDetailById(Long detailid);

    /**
     * 判断用户是否做过调查
     * @return 一个明细
     */
    Integer selectDetailByIPandId(@Param("researchid") Long researchid,@Param("ip") String ipaddress);
    /**
     * 显示一次调查的所有明细
     * @param researchid
     * @return 明细
     */
    List<ResearchDetail> selectDetailsByResearch(Long researchid);

    /**
     * 显示一次明细里所有的题目?
     * @param detailid
     * @return 明细
     */
    List<Poll> selectAllPollsByDetailId(Long detailid);
    /**
     * 修改明细有效性
     * @param detailid 要无效的数据
     */
    void alterResearchDetails(@Param("ids") List<Long> detailid);
    /**
     * 通过id找到research条数
     * @param detailid 要无效的数据
     */
    Integer countDetailByResearchId(Long researchid);
    /**
     * 通过id找到research条数
     * @param researchid researchid
     */
    Double selectAVGByResearchID(Long researchid);
}

